package unclassified.simple;


public class FindTheTownJudge_997 {

    public int findJudge(int n, int[][] trust) {
        int[] in = new int[n + 1], out = new int[n + 1];
        for (int[] ints : trust) {
            int a = ints[0], b = ints[1];
            in[b]++;
            out[a]++;
        }
        for (int i = 1; i <= n; i++) {
            if (in[i] == n - 1 && out[i] == 0) {
                return i;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        FindTheTownJudge_997 ft = new FindTheTownJudge_997();
        System.out.println(ft.findJudge(3, new int[][]{{1, 3},{2, 3}}));
    }
}
